<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="121px">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>基本信息</span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="预案类型" prop="PlanType" style="width: 330px">
              <!-- <el-input v-model="form.PlanType" placeholder="请输入预案类型" /> -->
              <el-select v-model="form.PlanType" placeholder="请选择预案类型">
                <el-option v-for="item in PlanTypeDropdownBox" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="预案名称" prop="PlanName" style="width: 330px">
              <el-input v-model="form.PlanName" placeholder="请输入预案名称" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="事故风险" prop="AccidentRisk" style="width: 330px">
              <el-input v-model="form.AccidentRisk" placeholder="请输入事故风险" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="事故类型" prop="AccidentType" style="width: 330px">
              <el-select v-model="selectedOptions" multiple placeholder="请选择事故类型">
                <el-option v-for="item in Listofaccidenttypes" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="可能发生区域" prop="PossibleOccurArea" style="width: 330px">
              <el-input v-model="form.PossibleOccurArea" placeholder="请输入可能发生区域" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="可能联动范围" prop="Possiblelinkage" style="width: 330px">
              <el-select v-model="rangeOptions" multiple placeholder="请选择可能联动范围">
                <el-option v-for="item in Listofpossiblelinkageranges" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="可能严重程度" prop="PossibleSeverity" style="width: 330px">
              <el-input v-model="form.PossibleSeverity" placeholder="请输入可能严重程度" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="可能发生时间" prop="PossibleTime" style="width: 330px">
              <el-input v-model="form.PossibleTime" placeholder="请输入可能发生时间" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="可能影响范围" prop="PossibleEffectScope" style="width: 330px">
              <el-input v-model="form.PossibleEffectScope" placeholder="请输入可能影响范围" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="可能衍生事故" prop="PossibleMatter" style="width: 330px">
              <el-input v-model="form.PossibleMatter" placeholder="请输入可能衍生事故" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="事故发生范围" prop="AccidentScope" style="width: 330px">
              <el-input v-model="form.AccidentScope" placeholder="请输入事故发生范围（全厂/某产线）" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="事故发生区域" prop="AccidentArea" style="width: 330px">
              <el-input v-model="form.AccidentArea" placeholder="请输入事故发生区域" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="事故发生设备" prop="AccidentPoint" style="width: 330px">
              <el-input v-model="form.AccidentPoint" placeholder="请输入事故发生设备" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="响应等级" prop="Responselevel" style="width: 330px">
              <el-select v-model="form.Responselevel" placeholder="请选择响应等级" @change="updateGradeName">
                <el-option v-for="item in Responselevellist" :key="item.grade" :label="item.grade" :value="item.grade">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="等级名称" prop="Gradename" style="width: 330px">
              <el-input disabled v-model="form.Gradename" placeholder="请输入事故发生设备" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="注意事项" prop="Notes" style="width: 330px">
              <el-input v-model="form.Notes" placeholder="请输入注意事项" type="textarea" :rows="1" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>事故预警征兆</span>
        </div>
        <el-col :span="8">
          <el-form-item label="事故预警征兆" prop="AccidentWarnSign" style="width: 330px">
            <el-input v-model="form.AccidentWarnSign" placeholder="请输入事故征兆" type="textarea" :rows="1" />
            <!-- <editor v-model="form.AccidentWarnSign" :min-height="192" /> -->
          </el-form-item>
        </el-col>
        <el-col :span="8" style="margin-left: 30px">
          <el-form-item label="征兆处置措施" prop="AccidentWarnDeal" style="width: 330px">
            <el-input v-model="form.AccidentWarnDeal" placeholder="请输入征兆处置措施" type="textarea" :rows="1" />
            <!-- <editor v-model="form.AccidentWarnDeal" :min-height="192" /> -->
          </el-form-item>
        </el-col>
      </el-card>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>具体步骤</span>
        </div>
        <el-card class="box-card" v-for="(Activity, disposalIndex) in ActivityAreaList" :key="disposalIndex"
          style="margin-top: 20px">
          <el-row>
            <el-col :span="6">
              <div style="display: flex">
                <div style="
                    line-height: 36px;
                    font-size: 15px;
                    color: #606266;
                    font-weight: 700;
                    margin-right: 10px;
                  ">
                  区域/设备
                </div>
                <el-select clearable v-model="Activity.zoneofaction" placeholder="请选择区域/设备" style="width: 170px">
                  <el-option label="区域" value="区域"></el-option>
                  <el-option label="设备" value="设备"></el-option>
                </el-select>
                <div style="margin-left: 1%">
                  <el-button type="text" icon="el-icon-plus" v-if="disposalIndex === ActivityAreaList.length - 1"
                    @click="addArea(disposalIndex)" circle></el-button>
                </div>
                <div style="margin-left: 1%">
                  <el-button type="text" icon="el-icon-minus" @click="removedArea(disposalIndex)" circle></el-button>
                </div>
              </div>
            </el-col>
            <el-col :span="8">
              <div style="display: flex">
                <div style="
                    line-height: 36px;
                    font-size: 15px;
                    color: #606266;
                    font-weight: 700;
                    width: 101px;
                  ">
                  区域/地点名称
                </div>
                <el-input v-model="Activity.AccidentArea" autocomplete="off" placeholder="请输入区域/地点名称"
                  style="width: 284px"></el-input>
              </div>
            </el-col>
            <el-col :span="5">
              <div style="display: flex">
                <div style="
                    line-height: 36px;
                    font-size: 15px;
                    color: #606266;
                    font-weight: 700;
                    width: 130px;
                  ">
                  处置措施名称
                </div>
                <el-input v-model="Activity.MeasureName" placeholder="请输入处置措施名称" autocomplete="off"
                  style="width: 284px"></el-input>
              </div>
            </el-col>
          </el-row>

          <!-- 序号 -->
          <el-row style="margin-top: 30px">
            <el-col :span="4">
              <el-card class="box-card">
                <div slot="header" class="clearfix">
                  <span>处置序号</span>
                  <el-button style="float: right; padding: 3px 0" type="text"
                    @click="addDisposal(disposalIndex)">+</el-button>
                </div>
                <div v-for="(Disposal, index) in Activity.Disposalserialnumber" :key="index">
                  <div :style="{
                    display: 'flex',
                    lineHeight: '36px',
                    justifyContent: 'space-between',
                    color:
                      Activity.currentDisposal === index
                        ? '#038ff3'
                        : 'initial',
                    cursor: 'pointer',
                  }" @click="showCard(disposalIndex, index)">
                    NO.{{ index + 1 }}
                    <div>
                      <el-button type="text" @click="removeDisposal(disposalIndex, index)">-</el-button>
                    </div>
                  </div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="19" style="margin-left: 30px">
              <el-card v-if="isCardVisible" class="box-card">
                <div v-for="(Disposal, index) in Activity.Disposalserialnumber" :key="index"
                  v-show="Activity.currentDisposal === index">
                  <!-- 预案处理步骤和处理人员内容 -->
                  <div style="display: flex">
                    <div style="
                        line-height: 36px;
                        font-size: 15px;
                        color: #606266;
                        font-weight: 700;
                        margin-right: 10px;
                      ">
                      预案处理步骤
                    </div>
                    <el-select v-model="Disposal.DealStep" placeholder="请选择预案处理步骤">
                      <el-option v-for="item in Planprocessingstepsliest" :key="item" :label="item"
                        :value="item"></el-option>
                    </el-select>
                  </div>

                  <div style="margin-top: 30px" v-for="(item, itemIndex) in Disposal.divContents" :key="itemIndex">
                    <div style="display: flex">
                      <div style="
                          line-height: 36px;
                          font-size: 15px;
                          color: #606266;
                          font-weight: 700;
                          margin-right: 10px;
                        ">
                        处理人员
                      </div>
                      <el-select v-model="item.DealExecutor" placeholder="请选择">
                        <el-option v-for="person in Processingpersonnelliest" :key="person" :label="person"
                          :value="person"></el-option>
                      </el-select>
                      <div style="margin-left: 1%">
                        <el-button type="primary" plain v-if="itemIndex === Disposal.divContents.length - 1" @click="
                          addContentWithDealExecutor(
                            disposalIndex,
                            index,
                            itemIndex
                          )
                          ">+</el-button>
                      </div>
                      <div style="margin-left: 1%">
                        <el-button type="danger" plain @click="
                          removeContent(disposalIndex, index, itemIndex)
                          ">-</el-button>
                      </div>
                    </div>
                    <div style="
                        display: flex;
                        flex-wrap: wrap;
                        width: 1270px;
                        margin-left: 30px;
                      ">
                      <div v-for="(content, contentIndex) in item.contents" :key="contentIndex" style="
                          display: flex;
                          flex-wrap: wrap;
                          margin-top: 25px;
                          width: 344px;
                          margin-left: 6px;
                        ">
                        <div style="line-height: 34px">
                          {{ contentIndex + 1 }}.
                        </div>
                        <el-input type="textarea" :rows="1" placeholder="请输入处置内容" v-model="content.value" @input="
                          updateContent(
                            disposalIndex,
                            index,
                            itemIndex,
                            contentIndex
                          )
                          " style="margin-left: 20px; width: 178px"></el-input>
                        <div style="margin-left: 1%">
                          <el-button v-if="contentIndex === item.contents.length - 1" type="primary" plain @click="
                            addContents(
                              disposalIndex,
                              index,
                              itemIndex,
                              contentIndex
                            )
                            ">+</el-button>
                        </div>
                        <div style="margin-left: 1%">
                          <el-button v-if="contentIndex === item.contents.length - 1" type="danger" plain @click="
                            removeContents(
                              disposalIndex,
                              index,
                              itemIndex,
                              contentIndex
                            )
                            ">-</el-button>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>
        </el-card>
        <el-row style="margin-top: 20px">
          <el-col :span="8">
            <el-form-item label="" prop="remark">
              <el-button type="primary" @click="submitForm">确 定</el-button>
              <el-button @click="cancel">取 消</el-button>
            </el-form-item></el-col>
        </el-row>
      </el-card>
    </el-form>
  </div>
</template>
<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import {
  getLists,
  insertData,
  deletelist,
  ModifierList,
} from "../../api/Genericmethods/GeneralQuery.js";
// import Concretestep from "./concretestep.vue";
export default {
  // eslint-disable-next-line vue/no-unused-components
  // components: { Concretestep },
  props: {},
  data() {
    return {
      ActivityAreaList: [
        {
          zoneofaction: "",
          AccidentArea: "",
          MeasureName: "",
          // 左边的选中状态
          currentDisposal: 0,
          Disposalserialnumber: [
            {
              DealStep: "", //预案处理步骤
              divContents: [
                {
                  DealExecutor: "", //处理人员
                  contents: [{ value: "" }],
                },
              ],
            },
          ], // 存储处置信息的数组
        },
        // {
        //   zoneofaction: "区域",
        //   AccidentArea: "地点名称2",
        //   MeasureName: "处置措施名称2",
        //   // 左边的选中状态
        //   currentDisposal: 0,
        //   Disposalserialnumber: [
        //     {
        //       DealStep: "现场急救2", //预案处理步骤
        //       divContents: [
        //         {
        //           DealExecutor: "处理人员2", //处理人员
        //           contents: [{ value: "处置内容2" }, { value: "处置内容2-2" }],
        //         },
        //       ],
        //     },
        //   ], // 存储处置信息的数组
        // },
      ],
      isCardVisible: true,
      // 处理人员列表
      Processingpersonnelliest: [
        "第一目击者",
        "现场人员",
        "现场调度",
        "安全人员",
      ],
      // 预案处理步骤列表
      Planprocessingstepsliest: [
        "发出警报",
        "第一时间处置",
        "指挥救援",
        "现场急救",
        "善后处置",
      ],
      // 响应等级下拉框
      Responselevellist: [
        {
          grade: "III级",
          name: "班组级",
        },
        {
          grade: "II级",
          name: "公司级",
        },
        {
          grade: "I级",
          name: "社会级",
        },
      ],
      Listofaccidenttypes: [
        "火灾",
        "爆炸",
        "熔融金属爆炸",
        "煤粉粉尘爆炸",
        "锅炉爆炸",
        "容器爆炸",
        "起重伤害",
        "灼烫伤害",
        "化学灼伤",
        "机械伤害",
        "触电伤害",
        "物体打击",
        "车辆伤害",
        "坍塌",
        "淹溺",
        "高温危害",
        "低温冻伤",
        "噪声",
        "中毒窒息",
        "粉尘危害",
        "电离辐射",
        "自然灾害",
      ],
      // 预案类型下拉框
      PlanTypeDropdownBox: ["现场处置方案", "专项应急预案", "综合应急预案"],
      // 可能联动范围下拉框
      Listofpossiblelinkageranges: [
        "ERT集结",
        "区域疏散",
        "全员疏散",
        "周边企业",
        "外部专业救援队伍",
        "无",
      ],
      // 表单参数
      form: {
        AccidentArea: "", //事故发生区域
        AccidentPoint: "", //事故发生设备
        AccidentRisk: "", //事故风险
        AccidentScope: "", //事故发生范围（全厂/某产线）
        AccidentType: "", //事故类型
        AccidentWarnDeal: "", //事故预警措施
        AccidentWarnSign: "", //事故预警征兆
        Gradename: "", //等级名称
        Notes: "", //注意事项
        PlanName: "", //预案名称
        PlanType: "", //预案类型
        PossibleEffectScope: "", //可能影响范围
        PossibleMatter: "", //可能衍生事故
        PossibleOccurArea: "", //可能发生区域/地点
        PossibleSeverity: "", //可能严重程度
        PossibleTime: "", //可能发生时间
        Possiblelinkage: "", //可能联动范围
        Responselevel: "", //响应等级
      },
      rules: {
        PlanName: [
          { required: true, message: "请输入预案名称", trigger: "blur" },
          { validator: this.checkPlanNameUnique, trigger: "blur" },
        ],
        PlanType: [
          { required: true, message: "预案类型不能为空", trigger: "blur" },
        ],
        postSort: [
          { required: true, message: "岗位顺序不能为空", trigger: "blur" },
        ],
      },
    };
  },
  // 计算属性 类似于data概念
  computed: {
    paginatedItems() {
      const startIndex = (this.currentPage - 1) * this.pageSize;
      const endIndex = startIndex + this.pageSize;
      return this.filteredItems.slice(startIndex, endIndex);
    },
    totalPages() {
      return Math.ceil(this.filteredItems.length / this.pageSize);
    },
    // 事故类型下拉框
    selectedOptions: {
      get() {
        // 检查是否为空字符串，如果是，则返回空数组
        if (this.form.AccidentType === "") {
          return [];
        }
        // 否则，将以逗号分隔的字符串转换为数组
        return this.form.AccidentType.split(",");
      },
      set(value) {
        // 将选中的值组合为逗号分隔的字符串
        this.form.AccidentType = value.join(",");
      },
    },
    // 可能联动范围下拉框
    rangeOptions: {
      get() {
        // 检查是否为空字符串，如果是，则返回空数组
        if (this.form.Possiblelinkage === "") {
          return [];
        }
        // 否则，将以逗号分隔的字符串转换为数组
        return this.form.Possiblelinkage.split(",");
      },
      set(value) {
        // 将选中的值组合为逗号分隔的字符串
        this.form.Possiblelinkage = value.join(",");
      },
    },
  },
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    // 活动区域+
    addArea(ActivityIndex) {
      const newActivity = {
        zoneofaction: "",
        AccidentArea: "",
        MeasureName: "",
        // 新增添加左边默认选中list第一个元素
        currentDisposal: 0,
        Disposalserialnumber: [
          {
            DealStep: "", //预案处理步骤
            divContents: [
              {
                DealExecutor: "", //处理人员
                contents: [{ value: "" }],
              },
            ],
          },
        ],
      };
      // this.ActivityAreaList.splice(ActivityIndex + 1, 0, newActivity);
      this.ActivityAreaList.push(newActivity);
    },
    // 活动区域-
    removedArea(ActivityIndex) {
      if (this.ActivityAreaList.length > 1) {
        this.ActivityAreaList.splice(ActivityIndex, 1);
      }
    },
    addDisposal(ActivityIndex) {
      const newDisposal = {
        index:
          this.ActivityAreaList[ActivityIndex].Disposalserialnumber.length + 1,
        DealStep: "", //预案处理步骤
        divContents: [
          {
            DealExecutor: "", //处理人员
            contents: [{ value: "" }],
          },
        ],
      };
      this.ActivityAreaList[ActivityIndex].Disposalserialnumber.push(
        newDisposal
      ); // 将新的处置添加到数组中
    },
    removeDisposal(ActivityIndex, index) {
      this.ActivityAreaList[ActivityIndex].Disposalserialnumber.splice(
        index,
        1
      ); // 从数组中删除指定序号的处置
      if (this.currentDisposal === index) {
        this.isCardVisible = false;
        this.currentDisposal = 0;
      }
    },
    showCard(ActivityIndex, index) {
      // 把index提到数组对象里面控制左边的切换
      this.ActivityAreaList[ActivityIndex].currentDisposal = index;
      this.isCardVisible = true;
    },
    // 处理人员+
    addContentWithDealExecutor(ActivityIndex, disposalIndex, contentIndex) {
      const newItem = {
        DealExecutor: "",
        contents: [{ value: "" }],
      };
      this.ActivityAreaList[ActivityIndex].Disposalserialnumber[
        disposalIndex
      ].divContents.splice(contentIndex + 1, 0, newItem);
    },
    // 处理人员-
    removeContent(ActivityIndex, disposalIndex, contentIndex) {
      if (
        this.ActivityAreaList[ActivityIndex].Disposalserialnumber[disposalIndex]
          .divContents.length > 1
      ) {
        this.ActivityAreaList[ActivityIndex].Disposalserialnumber[
          disposalIndex
        ].divContents.splice(contentIndex, 1);
      }
    },
    // 处置内容输入框内容
    updateContent(ActivityIndex, disposalIndex, contentIndex, innerIndex) {
      const content =
        this.ActivityAreaList[ActivityIndex].Disposalserialnumber[disposalIndex]
          .divContents[contentIndex].contents[innerIndex];
    },
    // 处置内容+
    addContents(ActivityIndex, disposalIndex, contentIndex, innerIndex) {
      const newContent = { value: "" };
      this.ActivityAreaList[ActivityIndex].Disposalserialnumber[
        disposalIndex
      ].divContents[contentIndex].contents.splice(
        innerIndex + 1,
        0,
        newContent
      );
    },
    // 处置内容-
    removeContents(ActivityIndex, disposalIndex, contentIndex, innerIndex) {
      if (
        this.ActivityAreaList[ActivityIndex].Disposalserialnumber[disposalIndex]
          .divContents[contentIndex].contents.length > 1
      ) {
        this.ActivityAreaList[ActivityIndex].Disposalserialnumber[
          disposalIndex
        ].divContents[contentIndex].contents.splice(innerIndex, 1);
      }
    },
    // 校验
    checkPlanNameUnique(rule, value, callback) {
      for (const item of this.$route.query.data) {
        if (value === item.PlanName) {
          this.$message.error("预案名称已存在");
        } else {
          callback();
        }
      }
    },
    // 响应等级
    updateGradeName() {
      const selectedGrade = this.form.Responselevel;
      const selectedLevel = this.Responselevellist.find(
        (item) => item.grade === selectedGrade
      );
      this.form.Gradename = selectedLevel ? selectedLevel.name : "";
    },
    // 取消按钮
    cancel() {
      this.$router.go(-1);
      this.$refs["form"].resetFields();
    },
    // 提交按钮
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          // 具体步骤添加
          const PlanName = this.form.PlanName;
          const PlanType = this.form.PlanType;
          const ActivityAreaList = this.ActivityAreaList;
          const sqllist =
            '`PlanType`,`PlanName`,`AccidentArea`,`AccidentPoint`,`DealCode`,`DealStep`,`MeasureName`,`DealExecutor`,`DealContent1`,`DealContent2`,`DealContent3`,`DealContent4`,`DealContent5`,`DealContent6`,`DealContent7`,`DealContent8`,`DealContent9`,`DealContent10`';
          const insertSql = [];
          for (let i = 0; i < ActivityAreaList.length; i++) {
            const area = ActivityAreaList[i];
            let AccidentArea = "";
            let AccidentPoint = "";

            if (area.zoneofaction === "设备") {
              AccidentPoint = area.AccidentArea;
            } else if (area.zoneofaction === "区域") {
              AccidentArea = area.AccidentArea;
            }
            for (let j = 0; j < area.Disposalserialnumber.length; j++) {
              const disposal = area.Disposalserialnumber[j];

              for (let k = 0; k < disposal.divContents.length; k++) {
                const content = disposal.divContents[k];

                const dealCode = j + 1;
                // let sql = `INSERT INTO IMP." EmergPlan_SiteRspMrs_Deal" ("PlanType","PlanName","AccidentArea","AccidentPoint","DealCode","DealStep","MeasureName","DealExecutor","DealContent1","DealContent2","DealContent3","DealContent4","DealContent5","DealContent6","DealContent7","DealContent8","DealContent9","DealContent10") VALUES (`;
                let sql = `'${PlanType}','${PlanName}','${AccidentArea}','${AccidentPoint}','${dealCode}','${disposal.DealStep}','${area.MeasureName}','${content.DealExecutor}'`;

                for (let l = 0; l < 10; l++) {
                  const value = content.contents[l]?.value || ""; // 如果值为 undefined 或 null，则设置为空字符串
                  sql += `,'${value}'`;
                }
                insertSql.push(sql);
              }
            }
          }
          for (let index = 0; index < insertSql.length; index++) {
            const element = insertSql[index];
            insertData("EmergPlan_SiteRspMrs_Deal", sqllist, element)
              .then((res) => {
                if (res.data.code === 1) {
                  // this.$modal.msgSuccess("具体步骤新增成功");
                } else {
                  this.$message.error(res.data.message);
                }
                this.OperationLog(res, this.$route.meta.title);
              })
              .catch((err) => {
                console.log(err);
              });
          }
          // 基本信息添加操作
          const fieldlist = Object.keys(this.form)
            .map((field) => `\`${field}\``)
            .join(",");
          const result = `${Object.values(this.form)
            .map((value) => `'${value}'`)
            .join(",")}`;
          insertData("EmergPlan_SiteRspMrs", fieldlist, result)
            .then((res) => {
              if (res.data.code === 1) {
                this.$modal.msgSuccess("基本信息新增成功");
                this.$router.go(-1);
              } else {
                this.$message.error(res.data.message);
              }
              this.OperationLog(res, this.$route.meta.title);
            })
            .catch((err) => {
              console.log(err);
            });
        } else {
          return this.$message.error(false);
        }
      });
    },
    OperationLog(res, title) {
      // INSERT INTO IMP."OperationLogList" ("timestamp","SQL","TIP","code","message","title") VALUES ('1','2','3','4','6','7')
      const timestamp = "'" + res.data.timestamp + "'";
      const SQL = "'" + res.getAllParams.SQL.replace(/'/g, "\\'") + "'";
      const TIP = "'" + res.getAllParams.TIP + "'";
      const code = "'" + res.data.code + "'";
      const message = "'" + res.data.message + "'";
      const titles = "'" + title + "'";
      const parameter = "OperationLogList";
      const fieldlist = '`timestamp`,`SQL`,`TIP`,`code`,`message`,`title`';
      const result = `${timestamp}, ${SQL}, ${TIP}, ${code}, ${message}, ${titles}`;
      insertData(parameter, fieldlist, result);
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() { },
  beforeCreate() { }, // 生命周期 - 创建之前
  beforeMount() { }, // 生命周期 - 挂载之前
  beforeUpdate() { }, // 生命周期 - 更新之前
  updated() { }, // 生命周期 - 更新之后
  beforeDestroy() { }, // 生命周期 - 销毁之前
  destroyed() { }, // 生命周期 - 销毁完成
  activated() { }, // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="scss" scoped>
.box-card {
  margin-top: 3%;
}

::v-deep .el-form-item__label {
  text-align: left;
}
</style>
